package com.zhou.review2.controller;



import com.zhou.review2.entity.User;
import com.zhou.review2.serviceImpl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/User")
public class UserController {
    //自动注入,业务对象
    @Autowired
    UserServiceImpl userServiceImpl;
    //select,list,分层的请求形式
    @RequestMapping("list.do")
    public String list(Model model){
        List<User> users=userServiceImpl.list();
        model.addAttribute("users",users);
        return "listUsers";
    }

    @RequestMapping("delete.do")
    public String delete(int id,Model model){
        userServiceImpl.removeById(id);
        return list(model);
    }



}
